/**
 * @description 前端命令行接口
 * @author zhangli
 * @dateTime 2023-02-05
 */
import express from 'express'
import { findMany, deleteMany, insertMany } from '../middleware/mongodb.js'

const app = express.Router()

/**
 * @description 前端开发常用命令行
 */
app.get('/getCliList', async (req, res) => {
  const data = await findMany('cli', req.query)
  res.send({
    code: 200,
    data,
  })
})

// 新增命令行
app.post('/addCli', async (req, res) => {
  await insertMany('cli', req.body)
  res.send({
    code: 200,
  })
})

// 删除命令行
app.post('/delCli', async (req, res) => {
  const { _id } = req.body
  await deleteMany('cli', { _id })
  res.send({
    code: 200,
  })
})

export default app
